//
//  MainTabBarController.swift
//  SinaMicroBlog
//
//  Created by xinjuwen on 15/10/19.
//  Copyright © 2015年 xinjuwen. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {

    //编辑按钮单击事件
    func composeBtnCli() {
        print("composeBtnCli")
    }
    
    lazy var addBtn: UIButton = {
        //设置一个临时button
        var tempBtn = UIButton(backgroundImage: "tabbar_compose_button", iconImage: "tabbar_compose_icon_add")
        
        //设置单击事件
        tempBtn.addTarget(self, action: "composeBtnCli", forControlEvents: .TouchUpInside)
        
        //设置button中心位置
        tempBtn.center = CGPointMake(self.tabBar.bounds.width*0.5,self.tabBar.bounds.height*0.5)
        
        return tempBtn
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBar.bounds.height*0.5
        //设置tabBar字体和图标的着色颜色
        tabBar.tintColor = UIColor.orangeColor()
        
        tabBar.addSubview(addBtn)
        
        //设置TabBarController的viewControllers
        viewControllers =
            [HomeVisitorNavigationController(),       //首页访客页面
             MessageVisitorNavigationController(),    //消息访客页面
             UIViewController(),                      //给加号按钮站位的
             DiscoverVisitorNavigationController(),   //发现访客页面
             MeVisitorNavigationController()]         //我访客页面
//
//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (Int64)(2 * NSEC_PER_SEC)), dispatch_get_main_queue()) {
//             self.viewControllers = [HomeNavigationController()]
//        }
    }

    override func viewWillAppear(animated: Bool) {
        tabBar.bringSubviewToFront(addBtn)
    }
}
